import java.io.*;
import java.math.BigInteger;
import java.util.Scanner;
import java.util.StringTokenizer;

public class 素数判断_Miller_Rabin模板 {
    // https://www.luogu.com.cn/problem/U148828
    public static PrintWriter out = new PrintWriter(new BufferedWriter(new OutputStreamWriter(System.out)));
    public static Read in = new Read();
    public static int MAXN = 10001;
    public static long[] arr = new long[MAXN];
    public static void main(String[] args) throws IOException {
        int n = in.nextInt();
        for (int i = 0; i < n; i++) {
            arr[i] = in.nextLong();
        }
        BigInteger num;
        for (int i = 0; i < n; i++) {
            num = new BigInteger(String.valueOf(arr[i]));
            out.println(num.isProbablePrime(10) ? "Yes" : "No");
        }
        out.close();
    }

    public static class Read {
        public static StringTokenizer st = new StringTokenizer("");
        public static BufferedReader bf = new BufferedReader(new InputStreamReader(System.in));
        String next() throws IOException {
            while (!st.hasMoreTokens()) {
                st = new StringTokenizer(bf.readLine());
            }
            return st.nextToken();
        }
        int nextInt() throws IOException {
            return Integer.parseInt(next());
        }

        long nextLong() throws IOException {
            return Long.parseLong(next());
        }
    }
}
